<?php
  if (!defined('baseinfo')) {
    exitdata();
}  
?>
<script src="<?=baseinfo?>/js/vendor/binaryajax.js"></script>
<script src="<?=baseinfo?>/js/vendor/exif.js"></script>
<script src="<?=baseinfo?>/js/vendor/canvasResize.js"></script>
<script src="<?=baseinfo?>/js/vendor/jquery.Jcrop.min.js"></script>
<script src="<?=baseinfo?>/js/vendor/jquery.iuploader-1.0.js"></script>
<script>



$('#fromsignup').submit(function() {



var checkerror=new Array();
var rowerror=0;



if($('#fromsignup input[name="username"]').val()=="")
{
    
     checkerror[rowerror++]={msg:"Please insert Username",code:4,obj:$("#validateerror-signup")};
     $('#fromsignup input[name="username"]').focus();

}
if($('#fromsignup input[name="email"]').val()=="")
{
    
     checkerror[rowerror++]={msg:"Please insert Email",code:4,obj:$("#validateerror-signup")};
     $('#fromsignup input[name="email"]').focus();

}

if($('#fromsignup input[name="password"]').val()=="")
{
    
     checkerror[rowerror++]={msg:"Please insert Password",code:4,obj:$("#validateerror-signup")};
     $('#fromsignup input[name="password"]').focus();

}
//console.log($('#fromsignup input[name="agreecheck"]').is(":checked"));



if(rowerror==0)
{
loaddata();
$.post(serviceinfo+"signup",$('#fromsignup').serialize(),
function(data){
loadclosedata();
if(data.error.response)
{
alertboxtext(data.error.error,$("#validateerror-signup"));

}else
{

alertrightboxmsgonly('Sucess');
usermanagerdata();


}



});

return false;
}
else
{
//console.log(checkerror);
alertboxtext(checkerror,$("#validateerror-signup"));
}
return false;
});

var rownow=1;
var arraytype=new Array();
arraytype[0]='csv';
$('#feature'+rownow+'  .linkvdobutton').iuploader({
         'link':serviceinfo+'iuploadfile',
         'accept':'csv',
         'type':arraytype,
         'group':1,
         'onStartUpload':function(setting){
         
         
            loaddata();
       //  $('#feature'+rownow+' .ico2.icoCrtGrn').hide();
    //     $('#feature'+rownow+' .btnIco.upAddIco').hide();
         
//         var bytename=bytesToSize(setting['size'],2);
//         $('#feature'+rownow+' .desPlg.clTxt3.fs03').html(bytename);
        // $('#feature'+rownow+' .fileName').html(setting['fileold']);
         },
         'load':$('#feature'+rownow+' .desPlg.clTxt3.fs03'),
         'finish':$('#feature'+rownow+' .ico2.icoCrtGrn'),
         'isimg':false,
         'onUploadFinish':function(filename,filelink,setting){
         
         
         loadclosedata();
         $.post(serviceinfo+'uploaddata', {fileid:setting.fileid}, function(data) {
         
         alertrightboxmsgonly('Sucess');
         usermanagerdata();
         
         });
         //console.log(setting);
       //   $("#fileid-"+setting.id).val(setting.fileid);
//          $("#fileold-"+setting.id).val(setting.fileold);
         
         // $('#feature'+rownow+' .fileName').html('<a href="'+filelink+'" target="'+filelink+'">'+setting.fileold+'</a>');
       // $('#feature'+rownow+' .plgArea').html(' <video width="100%" height="360" controls><source src="'+filelink+'" type="video/mp4"></video>');
         
         

         //alert(filename);
         }
   });

     $( document ).ready(function() { 
     
     
  $( 'input[name="datedatafrom"]' ).datepicker({
defaultDate: "+1w",
changeMonth: true,
numberOfMonths: 1,
dateFormat:'dd/mm/yy',
onClose: function( selectedDate ) {
$( 'input[name="datedatato"]' ).datepicker( "option", "minDate", selectedDate );

}
});
  $( 'input[name="datedatato"]' ).datepicker({
defaultDate: "+1w",
changeMonth: true,
numberOfMonths: 1,
dateFormat:'dd/mm/yy',
onClose: function( selectedDate ) {
$( 'input[name="datedatafrom"]' ).datepicker( "option", "maxDate", selectedDate );
        
}
});

     });

var pagedata=1;
function usermanagerdata()
{

 $.get(serviceinfo+'getuseralldata2', {page:pagedata,search:$('#searchboxdata').val()}, function(data) {
 
 var code = '<tr class="clBd2 bdBtm clTxt2">\n';
code += '<th>\n';
code += '<span>ID</span>\n';
code += '</th>\n';
code += '<th>\n';
code += '<span>Register Date</span>\n';
code += '</th>\n';
code += '<th>\n';
code += '<span>Username</span>\n';
code += '</th>\n';
code += '<th>\n';
code += '<span>Email</span>\n';
code += '</th>\n';
code += '<th>Password</th>\n';
code += '<th>\n';
code += '<span>Role</span>\n';
code += '</th>\n';
<?if(creditenable==1){?>
code +='<th>Coin</th><th>+Coin</th>';
<?}?>

code += '<th>\n';
code += '<span>Active</span>\n';
code += '</th>\n';
code += '<th>Delete</th>\n';
code += '</tr>\n';



 if(data.data.length>0)
 {
       $.each(data['data'], function(key, value) {
       
       
code += '<tr id="rowuser-'+value.userid+'">\n';
code += '<td>'+value.userid+'</td>\n';
code += '<td>'+value.newdate+'</td>\n';
code += '<td>'+value.username+'</td>\n';
code += '<td>'+value.email+'</td>\n';
code += '<td>\n';
code += '<button onclick="resetuserpassword('+value.userid+')" class="btnGen clTxtW cutTxt clBgBt1 fs03">Reset</button>\n';
code += '</td>\n';
code += '<td>\n';
code += '<div class="reDesignBe wrpLvlUser">\n';
code += '<select id="roleiddata-'+value.userid+'" onchange="changeroleiddatabyuserid('+value.userid+')" >\n';

var selectedrole=value.roleid;
if(selectedrole=='1')
{
code += '<option selected="selected" value="1">Member</option>\n';

}else
{
code += '<option  value="1">Member</option>\n';

}


if(selectedrole=='2')
{
code += '<option selected="selected" value="2">Member+</option>\n';

}else
{
code += '<option  value="2">Member+</option>\n';

}


if(selectedrole=='5')
{
code += '<option selected="selected" value="5">EOS Club</option>\n';

}else
{
code += '<option  value="5">EOS Club</option>\n';

}


if(selectedrole=='6')
{
code += '<option selected="selected" value="6">Contributor</option>\n';

}else
{
code += '<option  value="6">Contributor</option>\n';

}


if(selectedrole=='3')
{
code += '<option selected="selected" value="3">Admin</option>\n';

}else
{
code += '<option  value="3">Admin</option>\n';

}

if(selectedrole=='4')
{
code += '<option selected="selected" value="4">Super Admin</option>\n';

}else
{
code += '<option  value="4">Super Admin</option>\n';

}


code += '</select>\n';
code += '</div>\n';
code += '</td>\n';


<?if(creditenable==1){?>
code += '<td class="labelcoin">'+value.credit+'</td><td><div class="creditUser"><div class="reDesignBe wrpLvlUser"><select class="selectcoin"><option value="">Select</option><option value="100">100 Coins</option><option value="200">200 Coins</option></select></div><button onclick="addpaycredit('+value.userid+')" class="btnGen clTxtW cutTxt clBgBt1 fs03">OK</button></div></td>';
<?}?>




if(value.status=='1')
{
code += '<td><input type="checkbox" id="activedata-'+value.userid+'" value="1" onclick="activeuserdata('+value.userid+')" checked="checked"></td>\n';

}else
{
code += '<td><input type="checkbox" id="activedata-'+value.userid+'" onclick="activeuserdata('+value.userid+')" ></td>\n';

}

code += '<td>\n';


code += '<td>\n';
code += '<div class="trashUser">\n';
code += '<span class="ico icoTrash" onclick="deleterowuserdata('+value.userid+')"></span>\n';
code += '</div>\n';
code += '</td>\n';
code += '</tr>';

       }
       );
 }
 
 
 
 if(pagedata==1)
     {
     var fid=0;
     var param2='';
      //  console.log(1);
       setpagination('#pageAllwrpInPassZone',data['count'],1,'changefeaturedata',fid,param2,'');
     }
 
 
 $('table.tbUserLst tbody').html(code);
 
 
 
 });


}
function addpaycredit(userid)
{
var coin=$('#rowuser-'+userid+' .selectcoin').val();
if(coin)
{
 $.post(serviceinfo+'addpaycredit', {userid:userid,coin:coin}, function(data) {
 
 alertrightboxmsgonly('Sucess');

 var coinnow=$('#rowuser-'+userid+' .labelcoin').html();
 coinnow=parseInt(coinnow,10)+parseInt(coin,10);
 $('#rowuser-'+userid+' .labelcoin').html(coinnow);
 
 });
}else
{

alertwrongboxmsgonly('Please Select Coin');

}

}

function exportdatauser()
{
location.href='<?=baseinfo?>/ajax/exportuserall?nojson=1&datedatafrom='+$('input[name="datedatafrom"]').val()+'&datedatato='+$('input[name="datedatato"]').val();

}

function activeuserdata(userid)
{

var status=0;
if($('#activedata-'+userid).prop('checked') )
{

status=1;

}




$.post(serviceinfo+'activeuserdata', {userid:userid,status:status}, function(data) {



});

}

function changeroleiddatabyuserid(userid)
{

//console.log($('#roleiddata-'+userid).val());

$.post(serviceinfo+'changeroledata', {userid:userid,roleid:$('#roleiddata-'+userid).val() }, function(data) {



});

}

function deleterowuserdata(userid)
{
boxconfirmmsgdata('Do you want to Delete Userid '+userid,'deleterowuserdataset',userid);

}
function deleterowuserdataset(userid)
{

$.post(serviceinfo+'deleteuserdata', {userid:userid}, function(data) {

$('#rowuser-'+userid).remove();

});


}

function resetuserpassword(userid)
{


boxconfirmmsgdata('Do you want to reset Password Userid '+userid,'resetuserpasswordset',userid);




}

function resetuserpasswordset(userid)
{
$.post(serviceinfo+'forgetpassworddata', {userid:userid}, function(data) {



});

}

function changefeaturedata(page,fid,param2)
{
pagedata=page;
usermanagerdata();
}

usermanagerdata();
</script>